package gpsparser

import (
	"github.com/project-flogo/core/data/coerce"
)

// Settings activity settings
type Settings struct {
}

// Input activity input
type Input struct {
	Sentence string `md:"sentence,required" json:"sentence,omitempty"`
}

// FromMap construct input from map
func (r *Input) FromMap(values map[string]interface{}) error {
	sentence, err := coerce.ToString(values["sentence"])
	if err != nil {
		return err
	}
	r.Sentence = sentence
	return nil
}

// ToMap convert input to map
func (r *Input) ToMap() map[string]interface{} {
	return map[string]interface{}{
		"sentence": r.Sentence,
	}
}

// Output activity output
type Output struct {
	Data map[string]interface{} `md:"data"`
}

// FromMap construct output from map
func (o *Output) FromMap(values map[string]interface{}) error {
	data, err := coerce.ToObject(values["data"])
	if err != nil {
		return err
	}
	o.Data = data
	return nil
}

// ToMap convert output to map
func (o *Output) ToMap() map[string]interface{} {
	return map[string]interface{}{
		"data": o.Data,
	}
}
